package demo4.controller;

import com.detu.InputUtil;
import demo4.mapper.UserMapper;
import demo4.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserController {
    @Autowired
    private UserMapper userMapper;
    public void regUser(){
        User user = InputUtil.getInputObject(new User(),"欢迎注册");
        System.out.println("UserController:开始进行注册用户");
        if(userMapper.selectByUsername(user.getUsername())==null){
            userMapper.insert(user);
            System.out.println("恭喜您注册成功");
        }else {
            System.out.println("该用户已存在");
        }
    }
}
